package com.ifly.task.controller;

import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import com.ifly.task.pojo.Country;
import com.ifly.task.pojo.Type;
import com.ifly.task.pojo.User;
import com.ifly.task.repository.CountryRepository;
import com.ifly.task.repository.TypeRepository;
import com.ifly.task.repository.UserRepository;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @program: easyExcel
 * @description:
 * @author: xuYao2
 * @create: 2022-07-29 14:34
 **/
@RestController
@RequestMapping("api")
public class InitController {

    private final UserRepository userRepository;
    private final CountryRepository countryRepository;
    private final TypeRepository typeRepository;

    public InitController(UserRepository userRepository, CountryRepository countryRepository, TypeRepository typeRepository){
        this.userRepository = userRepository;
        this.countryRepository = countryRepository;
        this.typeRepository = typeRepository;
    }

    @PostMapping("/init")
    public void init(){

        ArrayList<User> userList = new ArrayList<>();
        userList.add(new User(1L, "赢政", 1, 1));
        userList.add(new User(2L, "孙尚香", 2, 12));
        userList.add(new User(3L, "宫本武藏", 1, 3));
        userList.add(new User(4L, "赢虔", 1, 4));
        userList.add(new User(5L, "欧阳修", 1, 5));
        userList.add(new User(6L, "郦食其", 1, 6));
        userList.add(new User(7L, "贾诩", 1, 7));
        userList.add(new User(8L, "法正", 1, 8));
        userList.add(new User(9L, "韩信", 1, 9));
        userList.add(new User(10L, "黄继光", 1, 10));
        userList.add(new User(11L, "李狗儿", 3, 11));
        userList.add(new User(12L, "滨崎步", 2, 12));
        userRepository.saveAll(userList);

        List<Country> countryList = new ArrayList<Country>();
        countryList.add(new Country(1L, "秦国", "嬴渠梁", "商鞅", new Date()));
        countryList.add(new Country(2L, "赵国", "赵雍", "楼缓", new Date()));
        countryList.add(new Country(3L, "齐国", "姜小白", "管仲", new Date()));
        countryList.add(new Country(4L, "魏国", "魏斯", "李悝", new Date()));
        countryList.add(new Country(5L, "燕国", "燕职", "乐毅", new Date()));
        countryRepository.saveAll(countryList);

        ArrayList<Type> typeDtoArrayList = new ArrayList<>();
        typeDtoArrayList.add(new Type(1L, "君王", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(2L, "勇士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(3L, "武士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(4L, "将军", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(5L, "文士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(6L, "辩士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(7L, "谋士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(8L, "军师", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(9L, "国士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(10L, "烈士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(11L, "男士", UUID.randomUUID().toString()));
        typeDtoArrayList.add(new Type(12L, "女士", UUID.randomUUID().toString()));
        typeRepository.saveAll(typeDtoArrayList);
    }
}
